package com.qiaofang.housewarehouse.stub.feign.client.impl;

import com.qiaofang.common.exception.BusinessException;
import com.qiaofang.housewarehouse.stub.constants.ResponseCode;
import com.qiaofang.housewarehouse.stub.facade.SaleHouseQueryFacade;
import com.qiaofang.housewarehouse.stub.feign.client.SaleHouseQueryClient;
import com.qiaofang.housewarehouse.stub.request.HouseQueryDetailRequest;
import com.qiaofang.housewarehouse.stub.request.SaleHouseQueryRequest;
import com.qiaofang.housewarehouse.stub.response.SaleHouseQueryDetailResponse;
import com.qiaofang.housewarehouse.stub.response.SaleHouseQueryResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SaleHouseQueryClientImpl implements SaleHouseQueryClient {

    @Autowired
    private SaleHouseQueryFacade saleHouseQueryFacade;
    @Override
    public SaleHouseQueryResponse searchSaleHouseList(SaleHouseQueryRequest saleHouseQueryRequest) {
        SaleHouseQueryResponse response = saleHouseQueryFacade.searchSaleHouseList(saleHouseQueryRequest);
        if (ResponseCode.RC_SUCCESS.getResponseCode().equals(response.getResponseCode())) {
            return response;
        } else {
            throw new BusinessException(response.getResponseCode(), response.getResponseMessage());
        }
    }

    @Override
    public SaleHouseQueryDetailResponse getSaleHouseDetail(HouseQueryDetailRequest saleHouseQueryRequest){
        SaleHouseQueryDetailResponse response = saleHouseQueryFacade.getSaleHouseDetail(saleHouseQueryRequest);
        if (ResponseCode.RC_SUCCESS.getResponseCode().equals(response.getResponseCode())) {
            return response;
        } else {
            throw new BusinessException(response.getResponseCode(), response.getResponseMessage());
        }
    }
}
